<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateDownloadRecordsTabel extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('download_records', function (Blueprint $table) {
            $table->increments('id');
            $table->string('order_sn')->comment('订单号');
            $table->integer('file_id')->comment('资源文件id');
            $table->integer('user_id')->comment('下载用户id');
            $table->integer('resource_id')->comment('资源类型id');
            $table->string('file_title')->nullable()->comment('资源文件名字');
            $table->string('resource_name')->nullable()->comment('资源类型名字');
            $table->integer('pay_amount')->default(0)->comment('支付金额');
            $table->enum('is_pay', ['wait', 'cancel', 'finish'])->default('wait')->comment('是否已付费');
            $table->timestamps();

            $table->index('order_sn');
            $table->unique('order_sn');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('download_records');
    }
}
